#include <stdio.h>
#include <stdlib.h>
int * input(){
	int *num = malloc(10 * sizeof(int));
	printf("Enter 10 numbers: ");
	for(int i=0;i<10;i++){
		scanf("%d",&num[i]);
	}
	return num;
}
void swap(int *a, int n) {
    int min = *(a + 0);
    int max = *(a + 0);
    int minIndex = 0;
    int maxIndex = 0;
    for (int i = 0; i < n; i++) {
        if (min > *(a + i)) {
            min = *(a + i);
            minIndex = i;
        }
        if (max < *(a + i)) {
            max = *(a + i);
            maxIndex = i;
        }
    }  
    // 将最大数与最后一位交换
    int temp = *(a + n - 1);
    *(a + n - 1) = max;
    *(a + maxIndex) = temp;
    
    // 将最小数与第一个数交换
    temp = *(a + 0);
    *(a + 0) = min;
    *(a + minIndex) = temp;
}
void print(int*a, int n){
	for(int i=0;i<n;i++){
		printf("%d ", *(a+i));
	}
	printf("\n");
}
int main(){
	int *p=input();
    swap(p, 10);
	print(p, 10);
	free(p);
	return 0;
}